package com.open.capacity.user.controller;

import com.open.capacity.common.model.SysUser;
import com.open.capacity.common.util.PageUtil;
import com.open.capacity.common.web.PageResult;

import com.open.capacity.common.web.Result;
import com.open.capacity.user.service.StudentService;
import io.swagger.annotations.Api;


import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author cheng
 * @date 2021-02-01 14:37
 * 学生
 */
@Slf4j
@Api(tags = "STUDENT API")
@RestController
public class StudentController {

    @Autowired
    private StudentService studentService;

    @ApiOperation(value = "班主任查询自己管理的所以学生")
    @GetMapping("/students")
    public PageResult<SysUser> findStudents(@RequestParam Map<String, Object> params) {
        PageUtil.pageParamConver(params, true);
        List<SysUser> list= studentService.findStudents(params);
        int count=studentService.findStudentsCount(params);
        return PageResult .<SysUser>builder().count((long) count).data(list).code(0).build();
    }

    @PostMapping("/updateGroupId")
    public Result updateGroupId(@RequestBody SysUser sysUser){
        return studentService.updateGroupId(sysUser);
    }
}
